package com.czkj.hwz.decorate.Activity;

import android.os.Build;
import android.support.v4.view.ViewPager;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.czkj.hwz.decorate.R;
import com.czkj.hwz.decorate.adapter.ViewPagerAdapter;
import com.czkj.hwz.decorate.base.BaseActivity;
import com.czkj.hwz.decorate.FirstActivity2;

public class GuidingActivity extends BaseActivity{
    private ViewPager guide_vp;
    private TextView guide_tv;
    private ViewPagerAdapter mViewPagerAdapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (Build.VERSION.SDK_INT >= 21){
            Window window = getWindow();
            //取消设置透明状态栏,使 ContentView 内容不再覆盖状态栏
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //需要设置这个 flag 才能调用 setStatusBarColor 来设置状态栏颜色
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            //设置状态栏颜色
            window.setStatusBarColor(getResources().getColor(R.color.yellow));
        }
        setContentView(R.layout.activity_guiding);
        getSupportActionBar().hide();
        guide_vp = (ViewPager) findViewById(R.id.guide_vp);
        guide_tv = (TextView) findViewById(R.id.guide_tv);
        mViewPagerAdapter=new ViewPagerAdapter(this);
        guide_vp.setAdapter(mViewPagerAdapter);

        initEvent();

    }



    private void initEvent() {
        guide_vp.setOnPageChangeListener(onPageChangeListener);
    }
    private ViewPager.OnPageChangeListener onPageChangeListener=new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int i, float v, int i1) {

        }

        @Override
        public void onPageSelected(int i) {
            switch (i){
                case 3:
                    new Thread(new Runnable() {
                        @Override
                        public void run() {
                            try {
                                Thread.sleep(1500);
//                                toOtherActivity(FristActivity.class);
//                                toOtherActivity(FirstActivity.class);
                                toOtherActivity(FirstActivity2.class);
                                finish();
//                                ed.putBoolean("isFirst", false);
//                                ed.apply();
//                                if(isFromWelcome){//如果是从设置界面进来
//                                    //将isFromSetting改为false
//                                    ed.putBoolean("isFromSetting", false);
//                                    ed.commit();
//                                    //点击跳过的时候，直接finish当前
//                                    finish();
//                                }else{
//                                }
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                        }
                    }).start();
                    break;
            }
        }

        @Override
        public void onPageScrollStateChanged(int i) {

        }
    };

}
